<template>
  <div>
    <Button size="large" type="text" @click="backHome">返回首页</Button>
    <Button size="large" type="text" @click="backPrev">返回上一页({{ second }}s)</Button>
  </div>
</template>

<script>
import "./error.less";
import { getSiteConfig } from "@/libs/util";
export default {
  name: "backBtnGroup",
  data() {
    return {
      second: 50,
      timer: null
    };
  },
  methods: {
    backHome() {
      let obj = getSiteConfig();
      this.$router.replace({
        name: obj ? obj.login : "index"
      });
    },
    backPrev() {
      this.$router.go(-1);
    }
  },
  mounted() {
    this.timer = setInterval(() => {
      if (this.second === 0) this.backPrev();
      else this.second--;
    }, 1000);
  },
  beforeDestroy() {
    clearInterval(this.timer);
  }
};
</script>
